package com.heima.kafka.producer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class HelloController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    /**
     * kafuka生产者
     * @return
     */
    @GetMapping("/hello")
    public String hello(){
        log.info("kafka生产者开启:");
        kafkaTemplate.send("itcast-topic","黑马程序员");
        return "ok";
    }
}